Crate exclusive_cell
source ·Expand description
This crate provides two thread-safe, non-blocking, no-std synchronization primitives: ExclusiveCell
and CallOnce
.
ExclusiveCell
can be accessed at most once and provides mutable access to the stored contents:
use exclusive_cell::ExclusiveCell;
static EXCLUSIVE_CELL: ExclusiveCell<usize> = ExclusiveCell::new(5);
let number = EXCLUSIVE_CELL.take().unwrap();
assert_eq!(number, &mut 5);
assert!(EXCLUSIVE_CELL.take().is_none());
CallOnce
can only be called once sucessfully:
use exclusive_cell::CallOnce;
static CALL_ONCE: CallOnce = CallOnce::new();
assert!(CALL_ONCE.call_once().is_ok());
assert!(CALL_ONCE.call_once().is_err());
Structs
A synchronization primitive that can only be called once sucessfully.
The
CallOnceError
error indicates that CallOnce::call_once
has been called more than once.A synchronization primitive which can be accessed only once.